package com.aaa.service.impl;

import com.aaa.dao.ViewResultSdsDao;
import com.aaa.entity.ViewResultSds;
import com.aaa.service.ViewResultSdsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yudejie2020
 */
@Service
public class ViewResultSdsServiceImpl implements ViewResultSdsService {

    @Autowired
    private ViewResultSdsDao viewResultSdsDao;

    @Override
    public String selectResult(Integer userId, String type) {
        if (type.equals("SDS性格色彩")) {
            //System.out.println("aaaaa");
            ViewResultSds viewResultSds = viewResultSdsDao.selectResultSds(userId);
            System.out.println(viewResultSds.toString());
            Integer a = Integer.parseInt(viewResultSds.getFordwordScoring()) + Integer.parseInt(viewResultSds.getReverseScoring());
            if (a <= 53) {
                return "SdsNormal";
            } else if (a < 62) {
                return "SdsMild";
            } else if (a < 72) {
                return "SdsModerate";
            } else {
                return "SdsSevere";
            }
        }
        return null;
    }

    /*
     * 测试结果
     * */
//
//    public String selectResult(Integer userId, String type) {
////        if (type.equals("FPA性格测试")) {
////            ViewFpa viewFpa = viewDao.seleResultFpa(userId);
////            double a = viewFpa.getRedCount();
////            double b = viewFpa.getYellowCount();
////            double c = viewFpa.getBlueCount();
////            double d = viewFpa.getGreenCount();
////            if (a > b && a > c && a > d) {
////                return "red";
////            } else if (b > a && b > c && b > d) {
////                return "yellow";
////            } else if (c > a && c > b && c > d) {
////                return "blue";
////            } else if (d > a && d > b && d > c) {
////                return "green";
////            } else {
////                return "all";
////            }
////        } else if (type.equals("SAS焦虑测试")) {
////            ViewSasSds viewSasSds = viewDao.seleResultSas(userId);
////            double a = viewSasSds.getForward() + viewSasSds.getInversion();
////            if (a <= 50) {
////                return "normalSas";
////            } else if (a < 60) {
////                return "mildSas";
////            } else if (a < 70) {
////                return "moderateSas";
////            } else {
////                return "severeSas";
////            }
//        if (type.equals("SDS抑郁测试")) {
//            ViewResultSds viewResultSds = viewResultSdsDao.selectResultSds(userId);
//            double a = Double.parseDouble(viewResultSds.getFordwordScoring() + viewResultSds.getReverseScoring());
//            if (a <= 53) {
//                return "SdsNormal";
//            } else if (a < 62) {
//                return "SdsMild";
//            } else if (a < 72) {
//                return "SdsModerate";
//            } else {
//                return "SdsSevere";
//            }
//        }
//        return null;
//    }
}
